package com.energyfuture.system.api.model;

import com.energyfuture.common.core.annotation.Excel;
import com.energyfuture.common.core.annotation.Excel.Type;
import com.energyfuture.common.core.annotation.Excels;
import com.energyfuture.common.core.web.domain.BaseEntity;
import com.energyfuture.system.api.domain.SysDept;
import com.energyfuture.system.api.domain.SysRole;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.util.Date;
import java.util.List;

/**
 * 用户对象 sys_user
 *
 * @author energyfuture
 */
public class RegisterUser extends BaseEntity {
    private static final long serialVersionUID = 1L;

    /**
     * 用户ID
     */
    @Excel(name = "用户序号",  prompt = "用户编号")
    private String userid;
    /**
     * 用户ID
     */
    @Excel(name = "单位序号",  prompt = "单位id")
    private String companyId;

    /**
     * 部门名称
     */
    @Excel(name = "部门名称", type = Type.IMPORT)
    private String deptname;

    /**
     * 职务
     */
    @Excel(name = "职务", type = Type.IMPORT)
    private String userpost;
    /**
     * 用户类型
     */
    @Excel(name = "用户类型", type = Type.IMPORT)
    private String usertype;
    /**
     * 用户账号
     */
    @Excel(name = "用户名称")
    private String username;
    /**
     * 手机号码
     */
    @Excel(name = "手机号码")
    private String phonenumber;
    /**
     * 密码
     */
    private String password;
    /**
     * 用户状态
     */
    private String status;


    public RegisterUser() {

    }


    public RegisterUser(String userId) {
        this.userid = userId;
    }

    public String getUserId() {
        return userid;
    }

    public void setUserId(String userId) {
        this.userid = userId;
    }

    public boolean isAdmin() {
        return isAdmin(this.userid);
    }

    public static boolean isAdmin(String userId) {
        return userId != null && "1".equals(userId) ;
    }





    @NotBlank(message = "用户账号不能为空")
    @Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符")
    public String getUserName() {
        return username;
    }

    public void setUserName(String userName) {
        this.username = userName;
    }

    @Size(min = 0, max = 11, message = "手机号码长度不能超过11个字符")
    public String getPhonenumber() {
        return phonenumber;
    }

    public void setPhonenNmber(String phoneNumber) {
        this.phonenumber = phoneNumber;
    }


    @JsonProperty
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getCompanyId() {
        return companyId;
    }

    public void setCompanyId(String companyId) {
        this.companyId = companyId;
    }

    public String getDeptName() {
        return deptname;
    }

    public void setDeptName(String deptName) {
        this.deptname = deptName;
    }

    public String getUserPost() {
        return userpost;
    }

    public void setUserPost(String userPost) {
        this.userpost = userPost;
    }

    public String getUserType() {
        return usertype;
    }

    public void setUserType(String userType) {
        this.usertype = userType;
    }


    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                .append("userId", getUserId())
                .append("userName", getUserName())
                .append("phonenumber", getPhonenumber())
                .append("password", getPassword())
                .append("createBy", getCreateBy())
                .append("createTime", getCreateTime())
                .append("updateBy", getUpdateBy())
                .append("updateTime", getUpdateTime())
                .toString();
    }
}
